﻿using System;
using System.Collections.Generic;
using System.Data.OleDb;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class DangNhap : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Console.WriteLine("Chao Ban DEn DAng Nhap!");
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Session["TenDN"] = null;


        string sUsername = txtTenDN.Text;
        string sPassw = txtMK.Text;
        string sQuery = "select * from THANHVIEN where TenDN='" + sUsername + "' and MatKhau='" + sPassw.MD5().MD5() + "'";

        try
        {
            Ketnoi.Open();
            OleDbDataAdapter da = new OleDbDataAdapter(sQuery, Ketnoi.Connect);
            DataTable dt = new DataTable();
            da.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                ThanhVien tv = new ThanhVien();
               
                Response.Redirect("TrangChu.aspx");
                //Response.Write(sUsername + "<h1>Chuc Mung Ban dang Nhap Thanh Cong!</h1>");
                //ThanhVien NguoiDangDN = new ThanhVien(sUsername, dt.Rows[0].ToString());
                //Session["TenDN"] = ;
            }
            else
            {
                lblKiemTra.Visible = true;
            }


        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
        Ketnoi.Close();

    }
    protected void txtTenDN_TextChanged(object sender, EventArgs e)
    {

    }
}